package Group9.TodoManager.View;

import java.awt.Color;

import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;

/**
 * TodoManagerTheme class is used for defining our own color theme for the
 * mainUI.
 * @author volkan cambazoglu
 *
 */
public class TodoManagerTheme extends DefaultMetalTheme {

    private ColorUIResource primary1;
    private ColorUIResource primary2;
    private ColorUIResource primary3;
    private ColorUIResource secondary1;
    private ColorUIResource secondary2;
    private ColorUIResource secondary3; 
    
    /**
     * Constructor. Creates an instance of the theme by using the provided
     * parameters 
     * @param primary1 first primary color
     * @param primary2 second primary color
     * @param primary3 third primary color
     * @param secondary1 first secondary color
     * @param secondary2 second secondary color
     * @param secondary3 third secondary color
     */
	public TodoManagerTheme(String primary1, String primary2, String primary3,
					String secondary1, String secondary2, String secondary3) {
		super();		
		
		this.primary1 = new ColorUIResource(parseColor(primary1));
		this.primary2 = new ColorUIResource(parseColor(primary2));
		this.primary3 = new ColorUIResource(parseColor(primary3));
		this.secondary1 = new ColorUIResource(parseColor(secondary1));
		this.secondary2 = new ColorUIResource(parseColor(secondary2));
		this.secondary3 = new ColorUIResource(parseColor(secondary3));
	}
	
	/**
	 * Parses the color from string
	 * @param color string of color in the format "0,0,0" without quotes
	 * @return color Color object
	 */
	private Color parseColor(String color){//0,0,0
		int red = Integer.parseInt(color.substring(0, color.indexOf(",")));
		String temp = color.substring(color.indexOf(",")+1);
		int green = Integer.parseInt(temp.substring(0, temp.indexOf(",")));
		temp = temp.substring(temp.indexOf(",")+1);
		int blue = Integer.parseInt(temp);
		return new Color(red,green,blue);
	}

	/**
	 * Getter method for name of the theme
	 * @return "TodoManager" without quotes
	 */
	public String getName() {
		return "TodoManager"; 
	}

	/**
	 * Getter method for first primary color
	 * @return primary1
	 */
    protected ColorUIResource getPrimary1() { 
    	return primary1; 
    }
    
    /**
	 * Getter method for second primary color
	 * @return primary2
	 */
    protected ColorUIResource getPrimary2() { 
    	return primary2; 
    }
    
    /**
	 * Getter method for third primary color
	 * @return primary3
	 */
    protected ColorUIResource getPrimary3() { 
    	return primary3;
    }

    /**
	 * Getter method for first secondary color
	 * @return secondary1
	 */
    protected ColorUIResource getSecondary1() {
		return secondary1;
	}

    /**
	 * Getter method for second secondary color
	 * @return secondary2
	 */
    protected ColorUIResource getSecondary2() {
		return secondary2;
	}

    /**
	 * Getter method for third secondary color
	 * @return secondary3
	 */
    protected ColorUIResource getSecondary3() {
		return secondary3;
	}
}
